Skip to content

Search events bug-fix#1821

Merged
tdonohue merged 3 commits intoDSpace:mainfrom
atmire:SearchEvents-bugfix
Sep 21, 2022
Merged

Search events bug-fix#1821
tdonohue merged 3 commits intoDSpace:mainfrom
atmire:SearchEvents-bugfix

Conversation

@Atmire-Kristof
Copy link
Copy Markdown
Contributor

References

Description

This PR fixes a bug with search-events not being sent to the rest api on search pages.
This bug happens because our tracking-component uses SearchConfigurationService's search options, which not every search component uses (e.g. the discover page), so it doesn't trigger a tracking event.

Instructions for Reviewers

List of changes in this PR:

  • Added trackSearch() to SearchService, using the same angularitics approach as the tracking component
  • Modified SearchComponent to call this method whenever a search is performed and trackStatistics (a new input defaulting to false) is true
  • Modified SearchPageComponent's template to set trackStatistics to true and remove the previous tracking component
  • The tracking component remains for usage on other places where it's still relevant

How to test:

  • Visit the /search page
  • Confirm a search event POST request is sent out to the rest api every time a search is performed
  • Verify the same happens when a query is performed using the search input in the header

Checklist

This checklist provides a reminder of what we are going to look for when reviewing your PR. You need not complete this checklist prior to creating your PR (draft PRs are always welcome). If you are unsure about an item in the checklist, don't hesitate to ask. We're here to help!

  • My PR is small in size (e.g. less than 1,000 lines of code, not including comments & specs/tests), or I have provided reasons as to why that's not possible.
  • My PR passes TSLint validation using yarn run lint
  • My PR doesn't introduce circular dependencies
  • My PR includes TypeDoc comments for all new (or modified) public methods and classes. It also includes TypeDoc for large or complex private methods.
  • My PR passes all specs/tests and includes new/updated specs or tests based on the Code Testing Guide.
  • If my PR includes new, third-party dependencies (in package.json), I've made sure their licenses align with the DSpace BSD License based on the Licensing of Contributions documentation.

@tdonohue tdonohue added bug component: Discovery related to discovery search or browse system component: statistics labels Sep 13, 2022
@tdonohue tdonohue added this to the 7.4 milestone Sep 13, 2022
@tdonohue tdonohue added the 1 APPROVAL pull request only requires a single approval to merge label Sep 15, 2022
@tdonohue tdonohue self-requested a review September 15, 2022 14:25
@tdonohue
Copy link
Copy Markdown
Member

@Atmire-Kristof : After merging #1791 (which is a larger, but important refactor), this now has some small merge conflicts. I'd appreciate it if you could rebase this again when you get the chance.

Copy link
Copy Markdown
Member

@tdonohue tdonohue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Thanks @Atmire-Kristof ! The code looks good, and I've verified that it fixes the issue as described. I now see the frontend sends a POST /server/api/statistics/searchevents which has a payload like this:

{"query":"test","page":{"totalElements":59,"totalPages":6,"number":1},"sort":{"by":"score","order":"desc"},"configuration":"default","scope":""}

@tdonohue tdonohue merged commit f01db3e into DSpace:main Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 APPROVAL pull request only requires a single approval to merge bug component: Discovery related to discovery search or browse system component: statistics

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Searches no longer trigger search events, or register in statistics

3 participants